<template>
  <div class="home">
    <div v-if="adHide" class="ad">
      <i class="iconfont icon-guanbi" @click="closeAd"></i>
      <a href="https://m.hua.com/mbzzy/?from=home">
        <img src="https://img02.hua.com/m/icon/m_home_download.png?v2" alt=""
      /></a>
    </div>
    <Header></Header>
    <Swiper></Swiper>
    <div class="goodWords">
      <ul>
        <li>
          <i class="iconfont icon-xiaolian"></i>
          <span>认证龙头企业</span>
        </li>
        <li>
          <i class="iconfont icon-xiaolian"></i>
          <span>16年品牌</span>
        </li>
        <li>
          <i class="iconfont icon-xiaolian"></i>
          <span>3小时送达</span>
        </li>
        <li>
          <i class="iconfont icon-xiaolian"></i>
          <span
            >最近<span class="num">{{ num }}</span
            >条好评</span
          >
        </li>
      </ul>
    </div>

    <!-- 中部列表 -->
    <div class="home-list">
      <ul>
        <li v-for="(item, idx) in listData" :key="idx">
          <img :src="item.imgUrl" alt="" />
          <span :class="idx < 5 ? 'cu' : ''">{{ item.name }}</span>
        </li>
      </ul>
    </div>

    <!-- 活动 -->
    <div class="activity">
      <img
        src="https://img02.hua.com/zhuanti/fatherday/2021/m_fatherday_mbanner.png"
        alt=""
        class="firstImg"
      />
      <div class="box1"></div>
    </div>
    <Tabbar></Tabbar>
  </div>
</template>
<script>
import Header from "../components/Home/Header.vue";
import Swiper from "../components/Home/Swiper.vue";
import Tabbar from "../components/common/Tabbar.vue";
import http from "../common/api/request";

export default {
  data() {
    return {
      adHide: true,
      num: 218234,
      listData: [],
    };
  },
  components: {
    Header,
    Tabbar,
    Swiper,
  },
  created() {
    this.getList();
  },
  methods: {
    closeAd() {
      this.adHide = false;
    },
    getList() {
      http
        .$axios({
          url: "/api/homelist",
        })
        .then((res) => {
          this.listData = res;
          console.log(this.listData);
        });
    },
  },
};
</script>
<style lang="scss" scoped>
.body {
  background-color: #ccc;
}
.ad {
  width: 100%;
  height: 48px;
  img {
    height: 100%;
    width: 100%;
  }
  i {
    position: fixed;
    left: 14px;
    top: 14px;
    color: #fff;
    z-index: 888;
  }
}

.header {
  width: 375px;
  height: 44px;
}

.goodWords {
  width: 351px;
  margin: auto;
  ul {
    display: flex;
    justify-content: space-between;
    li {
      i {
        font-size: 3px;
      }
      span {
        font-size: 3px;
        .num {
          text-decoration: underline;
        }
      }
    }
  }
}
.home-list {
  width: 351px;
  border-radius: 20px;
  background-color: #fff;
  margin: auto;
  margin-top: 10px;
  ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    li {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-top: 8px;
      margin-bottom: 8px;
      img {
        width: 40px;
        height: 39px;
      }
      span {
        width: 70px;
        height: 16px;
        font-size: 10px;
        text-align: center;
      }
      .cu {
        font-weight: bold;
      }
    }
  }
}

.activity {
  .firstImg {
    width: 375px;
    margin-bottom: -6px;
  }
  .box1 {
    width: 375px;
    height: 157px;
    background-color: rgb(232, 131, 105);
    margin-top: 0;
  }
}
</style>
